package cn.itcast.cn.itcast.lambda;

import org.junit.Test;

public class TestCal {
    @Test
    public void testCal(){
        method( (a ->{
                        if(a >0) {
                            return a;
                        }else{
                        return -a;
                        }
                    }));
        method(Math::abs);
    }

    @Test
    public void testSit(){
        method1(str -> System.out.println("将"+str+"做成可口的食物"));
        method1(Cook::makeFood);
        Cook cook = new Cook();
        method1(cook::makeFood1);
        method1(str -> System.out.println(str));
        method1(System.out::println);
    }


    public void method1(Sitter sitter) {
        sitter.work("白菜");
    }

    public void method(Calculator calculator){
        int result = calculator.sum(-10);
        System.out.println("结果是:"+result);

    }



    @Test
    public void test(){
        method3(System.out::println);
        method3(Cook::makeFood);
    }

    public void method3(Sitter sitter) {
        sitter.work("饺子");
    }

    public void method4(Calculator2 calculator){
        calculator.sum(-10);
        //System.out.println("结果是:"+result);

    }
    @Test
    public void test2(){
       // method4( s -> s+11);
        method4(CalculatorImpl2::hello1);
    }


}
